﻿using System;
using System.Collections.Generic;
using System.Text;

namespace dotHTML.HTML {
    /// <summary>
    /// Represents a logical section of a media element.
    /// </summary>
    [Standalone]
    [Serializable]
    public class Track : Element {
        /// <summary>
        /// Represents the choices for the kind of media this track referes to.
        /// </summary>
        public enum KindChoices {
            /// <summary>
            /// Represents a subtitles track.
            /// </summary>
            Subtitles,
            /// <summary>
            /// Represents a captions track.
            /// </summary>
            Captions,
            /// <summary>
            /// Represents descriptions of the video content.
            /// </summary>
            Descriptions,
            /// <summary>
            /// Represents chapter titles.
            /// </summary>
            Chapters,
            /// <summary>
            /// Represents tracks used by the script.
            /// </summary>
            Metadata
        }
        private bool _default;
        private KindChoices? _kind;
        private string _label;
        private string _src;
        private string _srclang;

        /// <summary>
        /// Constructs a new Track with the given URL.
        /// </summary>
        /// <param name="src">The URL of the track.</param>
        public Track(string src) {
            _src = src;
        }

        /// <summary>
        /// Determines whether or not this is the default track in the media
        /// element.
        /// </summary>
        public bool Default {
            get { return _default; }
            set { _default = value; }
        }

        /// <summary>
        /// Determines the type of track this is.
        /// </summary>
        public KindChoices? Kind {
            get { return _kind; }
            set { _kind = value; }
        }

        /// <summary>
        /// Determines a label to be presented to the user, describing this
        /// track.
        /// </summary>
        public string Label {
            get { return _label; }
            set { _label = value; }
        }

        /// <summary>
        /// Determines the URL of this track.
        /// </summary>
        public string Src {
            get { return _src; }
            set { _src = value; }
        }

        /// <summary>
        /// Determines the language of the URL of this track.
        /// </summary>
        public string SrcLang {
            get { return _srclang; }
            set { _srclang = value; }
        }

        /// <summary>
        /// Gets a formatted string of all local attributes of this element
        /// (not including the base attributes).
        /// </summary>
        /// <param name="sb">The StringBuilder to write this element's
        /// attribute data to.</param>
        protected override void WriteLocalAttributes(StringBuilder sb) {
            AttributeWriter.Write(sb, _default, "default");
            AttributeWriter.Write(sb, _kind, "kind", true);
            AttributeWriter.Write(sb, _label, "label");
            AttributeWriter.Write(sb, _src, "src");
            AttributeWriter.Write(sb, _srclang, "srclang");
        }

    }
}
